import Vue from 'vue'
import Router from 'vue-router'
// import home from '../view/index'
const home = q => require.ensure([], () => q(require('../views/index')), 'bundle');
const main = q => require.ensure([], () => q(require('../views/main')), 'bundle');
const cart = q => require.ensure([], () => q(require('../views/cart')), 'bundle');
const cases = q => require.ensure([], () => q(require('../views/case')), 'bundle');
const my = q => require.ensure([], () => q(require('../views/my')), 'bundle');
const login = q => require.ensure([], () => q(require('../views/login')), 'bundle');
Vue.use(Router)

export default new Router({
  routes: [
    { path: '*', redirect: { path: '/' }},
    {
      path: '/',
      name: 'home',
      component: home,
      children:[
        {
          path: '/',
          name: 'main',
          component: main
        }, {
          path: 'cases',
          name: 'cases',
          component: cases
        }, {
          path: 'my',
          name: 'my',
          meta: { auth: true },
          component: my
        }
        , {
          path: 'cart',
          name: 'cart',
          component: cart
        }
      ]
    },{
      path: '/login',
      name: 'login',
      component: login,
    }
  ]
})
